<template>
  <div class="right-chart-1">
    <div class="rc1-header">小易主机监控</div>
    <div class="rc1-chart-container">
      <dv-scroll-board :config="config" style="width:500px;height:220px" />
    </div>
  </div>
</template>
<script>
import { getNodeMetrics } from "@/api/metrics"

export default {
  name: 'RightChart1',
  data: function () {
    return {
      config: {
        data: []
      }
    }
  },
  mounted () {
    this.loadData()
    // eslint-disable-next-line no-unused-vars
    this.timer = setInterval(this.loadData, 1000 * 60)
  },
  beforeDestroy () {
    clearInterval(this.timer)
  },
  methods: {
    loadData: function () {
      getNodeMetrics().then(res => {
          this.config = {
            data: res.data.hostMetrics,
            header: ['主机', 'CPU(%)', 'Mem(%)', 'Disk(%)', '连接数'],
            align: ['center'],
            rowNum: 5,
            headerBGC: '#061423',
            columnWidth: [130, 85, 85, 85, 85],
            headerHeight: 50,
            oddRowBGC: 'rgba(4,18,29,0.8)',
            evenRowBGC: 'rgb(5,40,73)'
          }// this.data = res
        })
        .catch(function (res) {
          console.log(res)
        })
    }
  }
}
</script>

<style lang="less">
.right-chart-1 {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;

.rc1-header {
  text-align: center;
  height: 40px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 20px;
  margin-bottom: 5px;
}

.rc1-chart-container {
  flex: 1;
  display: flex;
}

.left {
  width: 30%;
  font-size: 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;

.number {
  font-size: 34px;
  color: #096dd9;
  font-weight: bold;
  margin-bottom: 30px;
}
}

.right {
  flex: 1;
  padding-bottom: 20px;
  padding-right: 20px;
  box-sizing: border-box;
}
}
</style>
